{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dog is running ...\n",
      "Oh, No, Tree is not running ...\n"
     ]
    }
   ],
   "source": [
    "class Animal(object):\n",
    "    def run(self):\n",
    "        print(\"Animal is running ...\")\n",
    "        \n",
    "class Dog(Animal):\n",
    "    def run(self):\n",
    "        print(\"Dog is running ...\")\n",
    "        \n",
    "class Botany(object):\n",
    "    def run(self):\n",
    "        print(\"Oh, No, Botany is not running ...\")\n",
    "        \n",
    "class Tree(Botany):\n",
    "    def run(self):\n",
    "        print(\"Oh, No, Tree is not running ...\")\n",
    "        \n",
    "def print_run(Animal):\n",
    "    # 只要对象由run这个属性，就可以执行\n",
    "    Animal.run()\n",
    "    \n",
    "dog = Dog()\n",
    "tree = Tree()\n",
    "\n",
    "print_run(dog) # 可以顺利执行\n",
    "print_run(tree)# 可以顺利执行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
